# --*-- conding:utf-8 --*--
# @Time: 2025/6/3 00:42
# @Author: Mark
# @Email: 17521559996@163.com
# @File: res_config_settings.py
# @Software : PyCharm

from odoo import models


class ResConfigSettings(models.TransientModel):
    _inherit = 'res.config.settings'

    def action_clear_all_data(self):
        tables = [
            'account_move_line',
            'account_move',
            'stock_move_line',
            'stock_move',
            'stock_picking',
            'purchase_order_line',
            'purchase_order',
            'sale_order_line',
            'sale_order',
        ]
        for table in tables:
            self.env.cr.execute(f'DELETE FROM {table} WHERE TRUE;')
        return {
            'type': 'ir.actions.client',
            'tag': 'display_notification',
            'params': {
                'title': '操作成功',
                'message': '所有业务表已直接清空！（极限暴力，注意检查关联表和脏数据）',
                'sticky': False,
            }
        }
